package com.xintoucloud.pbs.controller;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.xintoucloud.pbs.entity.PartyMemberExamObject;
import com.xintoucloud.pbs.model.DataGrid;
import com.xintoucloud.pbs.service.PartyMemberExamObjectService;

@Controller@RequestMapping("/ExamObject")
public class partyMemberExamObjectController {
	@Autowired
	private PartyMemberExamObjectService partyMemberExamObjectService;
	@RequestMapping("/list")
	public String listExamObject() {
		return "listExamObject";
	}
	@ResponseBody
	@RequestMapping("/listExamObject")
	public DataGrid<PartyMemberExamObject> listExamObject(HttpServletRequest request) {
		//1.获取参数
		 String page = request.getParameter("page");// 获取当前页 
		 String size = request.getParameter("limit");// 获取每页信息显示的条数 
		 int pages = Integer.parseInt(page); 
		 int rows = Integer.parseInt(size);  
		 // 查询总数 
		DataGrid<PartyMemberExamObject> pmeos=partyMemberExamObjectService.listPartyMemberExamObject(pages, rows);
		return pmeos;
	}
	@PostMapping("/add")
	public String insertExamObject(PartyMemberExamObject partyMemberExamObject,Model m) {
		partyMemberExamObjectService.insertPartyMemberExamObject(partyMemberExamObject);
		m.addAttribute("objectId", partyMemberExamObject.getObjectId());
		return "redirect:/ExamObject/list";
	}
	@ResponseBody
	@PostMapping("/delete")
	public PartyMemberExamObject deleteExamObject(int objectId) {
		partyMemberExamObjectService.deleteExamObject(objectId);
		PartyMemberExamObject pmeo=partyMemberExamObjectService.getPartyMemberExamObject(objectId);
		return pmeo;
	}
	@PostMapping("/update")
	public String updateExamObject(PartyMemberExamObjectService partyMemberExamObjectService) {
		partyMemberExamObjectService.updateExamObject(partyMemberExamObjectService);
		return "redirect:/ExamObject/list";
	}
}
